package com.chub.study.modules.entity;

import cn.hutool.core.date.DatePattern;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 * 报文表（请求报文，响应报文）
 * </p>
 *
 * @author Chub
 * @since 2022-11-02
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_message")
@ApiModel(value="TMessage", description="报文表（请求报文，响应报文）")
public class TMessage implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "报文UUID")
    @TableId(value = "MSG_ID")
    private String msgId;

    @ApiModelProperty(value = "发起渠道编号")
    @TableField("SEND_CHNL_CODE")
    private String sendChnlCode;

    @ApiModelProperty(value = "发起渠道名称")
    @TableField("SEND_CHNL_NAME")
    private String sendChnlName;

    @ApiModelProperty(value = "发起方流水号")
    @TableField("SEND_SRL_NUM")
    private String sendSrlNum;

    @ApiModelProperty(value = "发起时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN)
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @TableField("SEND_TIME")
    private LocalDateTime sendTime;

    @ApiModelProperty(value = "交易代码")
    @TableField("TRAN_CODE")
    private String tranCode;

    @ApiModelProperty(value = "交易名称")
    @TableField("TRAN_NAME")
    private String tranName;

    @ApiModelProperty(value = "请求类型(1-request, 2-post)")
    @TableField("REQ_TYPE")
    private String reqType;

    @ApiModelProperty(value = "请求URL")
    @TableField("REQ_URL")
    private String reqUrl;

    @ApiModelProperty(value = "处理状态(1-接收报文, 2-无效报文, 3-处理完成)")
    @TableField("HANDLE_STATE")
    private String handleState;

    @ApiModelProperty(value = "处理结果")
    @TableField("HANDLE_RESULT")
    private String handleResult;

    @ApiModelProperty(value = "报文内容")
    @TableField("MSG_CONTENT")
    private String msgContent;

    @ApiModelProperty(value = "报文主体")
    @TableField(exist = false)
    private JSONObject msgBody;

    @ApiModelProperty(value = "创建人")
    @TableField("CRT_USER")
    private String crtUser;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "CRT_TIME", fill = FieldFill.INSERT)
    private Date crtTime;

    @ApiModelProperty(value = "更新人")
    @TableField("UPT_USER")
    private String uptUser;

    @ApiModelProperty(value = "更新时间")
    @TableField(value = "UPT_TIME", fill = FieldFill.INSERT_UPDATE)
    // @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private Date uptTime;

    @ApiModelProperty(value = "有效标识（0-无效，1-有效）")
    @TableField("EFF_FLAG")
    private Integer effFlag;


}
